//
//  LYLSearchPictureCell.m
//  ONE
//
//  Created by dllo on 16/6/7.
//  Copyright © 2016年 GroupNine. All rights reserved.
//

#import "LYLSearchPictureCell.h"
#import <UIImageView+WebCache.h>

@interface LYLSearchPictureCell ()

/** 封面图片 */
@property (strong, nonatomic) UIImageView *coverView;
/** 标题 */
@property (strong, nonatomic) UILabel *titleLabel;
/** 内容简介 */
@property (strong, nonatomic) UILabel *contentLabel;

@end

@implementation LYLSearchPictureCell

+ (CGFloat)cellHeight {
    return 64;
}

#pragma mark - View Lifecycle

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        self.coverView = [UIImageView new];
        self.coverView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_coverView];
        [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.sizeOffset(CGSizeMake(65, 48));
            make.centerY.equalTo(self.contentView);
            make.left.equalTo(self.contentView).offset(8);
        }];
        
        self.titleLabel = [UILabel new];
        self.titleLabel.backgroundColor = [UIColor whiteColor];
        self.titleLabel.font = FontWithSize(13);
        self.titleLabel.textColor = LYLLightBlackTextColor;
        [self.contentView addSubview:_titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_coverView);
            make.left.equalTo(_coverView.mas_right).offset(8);
            make.right.equalTo(self.contentView);
        }];
        
        self.contentLabel = [UILabel new];
        self.contentLabel.backgroundColor = [UIColor whiteColor];
        self.contentLabel.font = FontWithSize(13);
        self.contentLabel.textColor = LYLLightBlackTextColor;
        [self.contentView addSubview:_contentLabel];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(_titleLabel);
            make.bottom.equalTo(_coverView);
        }];
    }
    return self;
}

//- (void)prepareForReuse {
//    [super prepareForReuse];
//    _coverView.image = nil;
//}

- (void)setModel:(LYLHomeItemModel *)model
{
    if (_model != model) {
        _model = model;
    }
    [_coverView sd_setImageWithURL:[NSURL URLWithString:model.hp_img_url] placeholderImage:[UIImage imageNamed:@"home_cover_placeholder"] options:SDWebImageRetryFailed];
    _titleLabel.text = model.hp_title;
    _contentLabel.text = model.hp_content;
}


@end
